<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>klsym</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="{{ asset('root/bower_components/bootstrap/dist/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('root/bower_components/font-awesome/css/font-awesome.min.css') }}">
    <link rel="stylesheet" href="{{ asset('root/bower_components/Ionicons/css/ionicons.min.css') }}">
    <link rel="stylesheet" href="{{ asset('root/dist/css/AdminLTE.min.css') }}">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet"
          href="{{ asset('/css/root.css')  }}">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        库拉索移民管理后台
    </div>

    <div class="login-box-body">
        <p class="login-box-msg">登录您的帐户</p>
        {!! Form::open(['url' => '/root/login','novalidate'=>'novalidate','id'=>'fb-form']) !!}

        <div class="form-group has-feedback">
            {!! Form::text('username',null, ['class' => 'form-control','placeholder'=>'用户名']) !!}
            <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
        </div>
        <div class="form-group has-feedback">
            {!! Form::password('pwd', ['class' => 'form-control','placeholder'=>'密码']) !!}
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        </div>
        <div class="row">
            <div class="col-xs-8">
                <div class="form-group">
                    <label class="error" id="errmsg"></label>
                </div>
            </div>
            <!-- /.col -->
            <div class="col-xs-4">
                <button type="submit" class="btn btn-primary btn-block btn-flat fb-submit">登录</button>
            </div>
            <!-- /.col -->
        </div>
        {!! Form::close() !!}
    </div>
</div>
<script src="{{asset('js/jquery.form.js')}}"></script>
<script src="{{asset('js/jquery.validate.min.js')}}"></script>
<script src="{{asset('js/jquery.validate.messages_zh.js')}}"></script>
<script>
  $(function () {
    var validator = $('#fb-form').validate({
      rules: {
        username: {
          required: true,
          maxlength: 50
        },
        pwd: {
          required: true
        }
      },
      messages: {
        username: '请输入用户名',
        pwd: '请输入密码'
      },
      submitHandler: function (form) {
        $(form).ajaxSubmit({
          dataType: 'json',
          beforeSubmit: function () {
            $('.fb-submit').prop('disabled', true).html('<i class="fa fa-spinner animate-spin"></i>');
          },
          success: function (res) {
            if (res.success) {
              $("#errmsg").hide();
              location.href = '/root/home';
            }
            else {
              $("#errmsg").show();
              $("#errmsg").html(res.message);
              $('.fb-submit').prop('disabled', false).html('登录');
            }
          }
        });
      }
    });

  });

</script>
</body>
</html>
